package com.ruoyi.reportInfo.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.reportInfo.domain.vo.IndustrialStationVo;
import com.ruoyi.reportInfo.domain.bo.IndustrialStationBo;
import com.ruoyi.reportInfo.service.IIndustrialStationService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场站基本信息
 *
 * @author yangzhen
 * @date 2025-11-24
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/reportInfo/station")
@Tag(name = "场站基本信息", description = "场站基本信息相关接口")
public class IndustrialStationController extends BaseController {

    private final IIndustrialStationService iIndustrialStationService;

    /**
     * 查询场站基本信息列表
     */
    @SaCheckPermission("reportInfo:station:list")
    @GetMapping("/list")
    @Operation(summary = "查询场站基本信息列表", description = "用于查询场站基本信息列表")
    public TableDataInfo<IndustrialStationVo> list(IndustrialStationBo bo, PageQuery pageQuery) {
        return iIndustrialStationService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出场站基本信息列表
     */
    @SaCheckPermission("reportInfo:station:export")
    @Log(title = "场站基本信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出场站基本信息列表", description = "用于导出场站基本信息列表")
    public void export(IndustrialStationBo bo, HttpServletResponse response) {
        List<IndustrialStationVo> list = iIndustrialStationService.queryList(bo);
        ExcelUtil.exportExcel(list, "场站基本信息", IndustrialStationVo.class, response);
    }

    /**
     * 获取场站基本信息详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("reportInfo:station:query")
    @GetMapping("/{id}")
    @Operation(summary = "获取场站基本信息详细信息", description = "用于获取场站基本信息详细信息")
    public R<IndustrialStationVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable String id) {
        return R.ok(iIndustrialStationService.queryById(id));
    }

    /**
     * 新增场站基本信息
     */
    @SaCheckPermission("reportInfo:station:add")
    @Log(title = "场站基本信息", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    @Operation(summary = "新增场站基本信息", description = "用于新增场站基本信息")
    public R<Void> add(@Validated(AddGroup.class) @RequestBody IndustrialStationBo bo) {
        return toAjax(iIndustrialStationService.insertByBo(bo));
    }

    /**
     * 修改场站基本信息
     */
    @SaCheckPermission("reportInfo:station:edit")
    @Log(title = "场站基本信息", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    @Operation(summary = "修改场站基本信息", description = "用于修改场站基本信息")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody IndustrialStationBo bo) {
        return toAjax(iIndustrialStationService.updateByBo(bo));
    }

    /**
     * 删除场站基本信息
     *
     * @param ids 主键串
     */
    @SaCheckPermission("reportInfo:station:remove")
    @Log(title = "场站基本信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @Operation(summary = "删除场站基本信息", description = "用于删除场站基本信息")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable String[] ids) {
        return toAjax(iIndustrialStationService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
